home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.09 Sep 90 / Debugger DA / RoundWDEF.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-26  |  4.8 KB  |  189 lines  |  [TEXT/KAHL]

  1. /********************************************************************/
  2. /*                                                                    */
  3. /*    Source  - RoundWDEF.c                                            */
  4. /*    Author  - Alexander S. Colwell, Copyright (C) 1988                */
  5. /*                                                                    */
  6. /*    Purpose - This is WDEF definition for "Debugger" DA's demo.        */
  7. /*                                                                    */
  8. /*    Routine - Main              : Main entry point module.            */
  9. /*              DoDrawMsg           : Do draw window frame message.        */
  10. /*              DoHitMsg           : Do mouse-hit window message.        */
  11. /*              DoCalcMsg        : Do calculate window message.        */
  12. /*              DoGrowMsg        : Do grow window message.            */
  13. /*                                                                    */
  14. /*    Revisions - None.                                                */
  15. /*                                                                    */
  16. /********************************************************************/
  17.  
  18. #include <WindowMgr.h>                /* Window Manager defs            */
  19. #include <SetUpA4.h>                /* Setup Register A4            */
  20. #include "Debugger.h"                /* Debugger defs                */
  21.  
  22.                                     /* Compilation directives        */
  23. #define    DEBUG                        /* Enable debugging stuff        */
  24.  
  25.                                     /* 'WDEF' entry point            */
  26. pascal long    main(varCode,theWindow,message,param)
  27.  
  28.     short        varCode;            /* Variation code                */
  29.     WindowPtr    theWindow;            /* Window pointer                */
  30.     short        message;            /* Message command                */
  31.     long        param;                /* Parameter control            */
  32.     
  33.     {
  34.     
  35.         long    status = 0L;        /* Working status indicator        */
  36.         
  37.         RememberA0();                /* Remember A0 global pointer    */
  38.         
  39.         SetUpA4();                    /* Setup register A4            */
  40.         
  41.         #ifdef DEBUG                /* Check if want debugging        */
  42.         
  43.                                     /* Output debugging info        */
  44.         DbgPrint(DbgGetRefHdl(),"WDEF: message - %d\n",message);
  45.                  
  46.         #endif
  47.         
  48.         switch(message) {            /* Process message handler        */
  49.         
  50.             case wNew:                /* Opening window                */
  51.                 break;
  52.                 
  53.             case wDispose:            /* Closing window                */
  54.                 break;
  55.                 
  56.             case wDraw:                /* Draw window frame            */
  57.                 DoDrawMsg(theWindow,param); break;
  58.                 
  59.             case wHit:                /* Check mouse down hits        */
  60.                 status = DoHitMsg(theWindow,param); break;
  61.                 
  62.             case wCalcRgns:            /* Calculate window's regions    */
  63.                 DoCalcMsg(theWindow); break;
  64.                 
  65.             case wGrow:                /* Grow window                    */
  66.                 DoGrowMsg(theWindow,param); break;
  67.                 
  68.             case wDrawGIcon:        /* Draw window's Grow Icon        */
  69.                 break;
  70.             
  71.         }
  72.         
  73.         RestoreA4();                /* Restore register A4            */
  74.         
  75.         return(status);                /* Return status indicator        */
  76.         
  77.     }
  78.  
  79. DoDrawMsg(theWindow,param)
  80.  
  81.     WindowPtr    theWindow;            /* Window pointer                */
  82.     long        param;                /* Message parameter            */
  83.     
  84.     {
  85.         
  86.         Rect        wRect;            /* Working window rect area        */
  87.         long        wPat[2];        /* Working white pattern        */
  88.         long        bPat[2];        /* Working black pattern        */
  89.         
  90.         if (!param) {                /* Check if want to frame it    */
  91.                     
  92.             wPat[0] = wPat[1] = 0L;    /* Init patterns                */
  93.             bPat[0] = bPat[1] = 0xFFFFFFFFL;
  94.  
  95.                                     /* Set window rect area            */
  96.             wRect = (*((WindowPeek)(theWindow))->strucRgn)->rgnBBox;
  97.             
  98.             PenNormal();            /* Reset pen characteristics    */
  99.             
  100.             FrameOval(&wRect);        /* Frame outer-most part        */
  101.             
  102.             InsetRect(&wRect,1,1);    /* Frame between part            */
  103.             PenPat(wPat);
  104.             FrameOval(&wRect);
  105.             
  106.             InsetRect(&wRect,1,1);    /* Frame middle part            */
  107.             PenSize(3,3);
  108.             PenPat(bPat);
  109.             FrameOval(&wRect);
  110.             
  111.             InsetRect(&wRect,3,3);    /* Frame between part            */
  112.             PenSize(1,1);
  113.             PenPat(wPat);
  114.             FrameOval(&wRect);
  115.  
  116.             InsetRect(&wRect,1,1);    /* Frame inter-most part        */
  117.             PenSize(1,1);
  118.             PenPat(bPat);
  119.             FrameOval(&wRect);
  120.         
  121.             InsetRect(&wRect,1,1);    /* Frame between part of content*/
  122.             PenPat(wPat);
  123.             FrameOval(&wRect);
  124.             PenPat(bPat);
  125.             
  126.         }
  127.         
  128.     }
  129.     
  130. DoHitMsg(theWindow,pt)
  131.  
  132.     WindowPtr    theWindow;            /* Window pointer                */
  133.     Point        pt;                    /* Mouse-down point                */
  134.     
  135.     {
  136.     
  137.         register short    status;        /* Working status flag            */
  138.         
  139.                                     /* Check if point inside region    */
  140.         if (PtInRgn(pt,((WindowPeek)(theWindow))->contRgn))
  141.             status = wInContent;    /* Yup, inside contents            */
  142.         else                        /* Nope, outside contents        */
  143.             status = wNoHit;        /* Set no hit indicator            */
  144.             
  145.         return(status);                /* Return hit status indicator    */
  146.         
  147.     }
  148.     
  149. DoCalcMsg(theWindow)
  150.  
  151.     WindowPtr    theWindow;            /* Window pointer                */
  152.     
  153.     {
  154.     
  155.         Rect    wRect;                /* Working window rect area        */
  156.         
  157.         wRect = theWindow->portRect;/* Set window rect area            */
  158.         
  159.                                     /* Normalize window rect area    */
  160.         OffsetRect(&wRect,-theWindow->portBits.bounds.left,
  161.                           -theWindow->portBits.bounds.top);
  162.                           
  163.                                       /* Setup content's region area    */
  164.         SetEmptyRgn(((WindowPeek)(theWindow))->contRgn);
  165.         OpenRgn();
  166.         FrameOval(&wRect);
  167.         CloseRgn(((WindowPeek)(theWindow))->contRgn);
  168.                           
  169.                                       /* Setup content's region area    */
  170.         SetEmptyRgn(((WindowPeek)(theWindow))->strucRgn);
  171.         OpenRgn();
  172.         InsetRect(&wRect,-8,-8);
  173.         FrameOval(&wRect);
  174.         CloseRgn(((WindowPeek)(theWindow))->strucRgn);
  175.                           
  176.     }
  177.     
  178. DoGrowMsg(theWindow,theRect)
  179.  
  180.     WindowPtr    theWindow;            /* Window pointer                */
  181.     Rect        *theRect;            /* Rect area to grow            */
  182.     
  183.     {
  184.     
  185.         FrameOval(theRect);            /* Draw the frame area            */
  186.         
  187.     }
  188.     
  189.